﻿$(document).ready(function () {

    Number.prototype.formatMoney = function (decPlaces, thouSeparator, decSeparator) {
        var n = this,
        decPlaces = isNaN(decPlaces = Math.abs(decPlaces)) ? 2 : decPlaces,
        decSeparator = decSeparator == undefined ? "." : decSeparator,
        thouSeparator = thouSeparator == undefined ? "," : thouSeparator,
        sign = n < 0 ? "-" : "",
        i = parseInt(n = Math.abs(+n || 0).toFixed(decPlaces)) + "",
        j = (j = i.length) > 3 ? j % 3 : 0;
        return sign + (j ? i.substr(0, j) + thouSeparator : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thouSeparator);
    };


    var USD = $("#VND-Amount").val() / $("#USD-Sell").text();
    $("#tbAmount").text("$"+USD.formatMoney(2,',','.'));
    $("#amount").val(USD.formatMoney(2, ',', '.'));

    $("#btnPaypal").click(function () {
        $("#thanhToan").submit();
    });
});